package org.goyo.main.domain.entity.storage;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.goyo.main.domain.entity.BaseEntryObject;
import org.goyo.main.domain.entity.base.BaseUnitMeasure;
import org.goyo.main.domain.entity.base.Material;
import org.goyo.main.domain.entity.base.MaterialEntry;
import org.goyo.main.domain.entity.base.Warehouse;
import org.goyo.main.domain.entity.sale.DispatchEntry;
import org.goyo.main.domain.entity.sale.SaleOrderEntry;
/**
 * 销售出库分录
 * 
 * @author chenchuan
 * 2014年11月12日
 */
@Entity
public class SaleOutStorageEntry extends BaseEntryObject implements Serializable {

	private static final long serialVersionUID = 1L;
	
//	/**
//	 * 发运单
//	 */
//	@ManyToOne
//	@JoinColumn(name="dispatchId")
//	private Dispatch dispatch;
	
	/**
	 * 发运单分录
	 */
	@ManyToOne
	@JoinColumn(name="dispatchEntryId")
	private DispatchEntry dispatchEntry;
	
//	/**
//	 * 销售订单
//	 */
//	@ManyToOne
//	@JoinColumn(name="saleOrderId")
//	private SaleOrder saleOrder;
	
	/**
	 * 销售订单分录
	 */
	@ManyToOne
	@JoinColumn(name="saleOrderEntryId")
	private SaleOrderEntry saleOrderEntry;
	
	/**
	 * 商品编码	
	 */
	@ManyToOne
	@JoinColumn(name="materialId")
	private Material material;
	/**
	 * 商品名称	
	 */
	@Column
	private String materialName;
	/**
	 * 商品规格型号	
	 */
	@Column
	private String materialStandard;
	/**
	 * 基本计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="jilUnitId")
	private BaseUnitMeasure jilUnit;
	
	/**
	 * 辅助计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="fjilUnitId")
	private MaterialEntry fjilUnit;
	/**
	 * 批次	
	 */
	@Column
	private String lot;
	/**
	 * 条码	
	 */
	@Column
	private String barCode;
	/**
	 * 保质到期日	
	 */
	@Column
	private String expiraDate;
	/**
	 * 数量	
	 */
	@Column
	private double outStorageQty = 0;
	
	 /**
     * 辅助换算率
     */
    @Column
    private String conversionRate;
	/**
	 * 辅助数量	
	 */
	@Column
	private double foutStorageQty = 0;
	/**
	 * 仓库	
	 */
	@ManyToOne
	@JoinColumn(name="warehouseId")
	private Warehouse warehouse;
	/**
	 * 出库单价	
	 */
	@Column
	private BigDecimal inStoragePrice = BigDecimal.ZERO;
	/**
	 * 出库金额	
	 */
	@Column
	private BigDecimal inStorageAmount = BigDecimal.ZERO;
	/**
	 * 税额	
	 */
	@Column
	private BigDecimal taxLimit = BigDecimal.ZERO;
	/**
	 * 价税合计	
	 */
	@Column
	private BigDecimal taxAmount = BigDecimal.ZERO;
	/**
	 * 核销数量	
	 */
	@Column
	private double cancelQty = 0;
	
	public String getMaterialName() {
		return materialName;
	}
	public void setMaterialName(String materialName) {
		this.materialName = materialName;
	}
	public String getMaterialStandard() {
		return materialStandard;
	}
	public void setMaterialStandard(String materialStandard) {
		this.materialStandard = materialStandard;
	}
	public String getLot() {
		return lot;
	}
	public void setLot(String lot) {
		this.lot = lot;
	}
	public String getBarCode() {
		return barCode;
	}
	public void setBarCode(String barCode) {
		this.barCode = barCode;
	}
	public String getExpiraDate() {
		return expiraDate;
	}
	public void setExpiraDate(String expiraDate) {
		this.expiraDate = expiraDate;
	}
	public Material getMaterial() {
		return material;
	}
	public BaseUnitMeasure getJilUnit() {
		return jilUnit;
	}
	public void setJilUnit(BaseUnitMeasure jilUnit) {
		if(jilUnit != null &&("".equals(jilUnit.getUuid()) || jilUnit.getUuid()==null))
			this.jilUnit = null;
		else
			this.jilUnit = jilUnit;	
	}
	public void setMaterial(Material material) {
		if(material != null &&("".equals(material.getUuid()) || material.getUuid()==null))
			this.material = null;
		else
			this.material = material;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public Warehouse getWarehouse() {
		return warehouse;
	}
	public void setWarehouse(Warehouse warehouse) {
		if(warehouse != null &&("".equals(warehouse.getUuid()) || warehouse.getUuid()==null))
			this.warehouse = null;
		else
			this.warehouse = warehouse;
	}
	public DispatchEntry getDispatchEntry() {
		return dispatchEntry;
	}
	public void setDispatchEntry(DispatchEntry dispatchEntry) {
		if(dispatchEntry != null &&("".equals(dispatchEntry.getUuid()) || dispatchEntry.getUuid()==null))
			this.dispatchEntry = null;
		else
			this.dispatchEntry = dispatchEntry;
	}
	public SaleOrderEntry getSaleOrderEntry() {
		return saleOrderEntry;
	}
	public void setSaleOrderEntry(SaleOrderEntry saleOrderEntry) {
		if(saleOrderEntry != null &&("".equals(saleOrderEntry.getUuid()) || saleOrderEntry.getUuid()==null))
			this.saleOrderEntry = null;
		else
			this.saleOrderEntry = saleOrderEntry;
	}
	public double getOutStorageQty() {
		return outStorageQty;
	}
	public void setOutStorageQty(double outStorageQty) {
		this.outStorageQty = outStorageQty;
	}
	public BigDecimal getInStoragePrice() {
		return inStoragePrice;
	}
	public void setInStoragePrice(BigDecimal inStoragePrice) {
		this.inStoragePrice = inStoragePrice;
	}
	public BigDecimal getInStorageAmount() {
		return inStorageAmount;
	}
	public void setInStorageAmount(BigDecimal inStorageAmount) {
		this.inStorageAmount = inStorageAmount;
	}
	public BigDecimal getTaxLimit() {
		return taxLimit;
	}
	public void setTaxLimit(BigDecimal taxLimit) {
		this.taxLimit = taxLimit;
	}
	public BigDecimal getTaxAmount() {
		return taxAmount;
	}
	public void setTaxAmount(BigDecimal taxAmount) {
		this.taxAmount = taxAmount;
	}
	public double getCancelQty() {
		return cancelQty;
	}
	public void setCancelQty(double cancelQty) {
		this.cancelQty = cancelQty;
	}
	
	public MaterialEntry getFjilUnit() {
    return fjilUnit;
  }
  public void setFjilUnit(MaterialEntry fjilUnit) {
    if(fjilUnit != null &&("".equals(fjilUnit.getUuid()) || fjilUnit.getUuid()==null))
      this.fjilUnit = null;
  else
      this.fjilUnit = fjilUnit;
  }
  public String getConversionRate() {
    return conversionRate;
  }
  public void setConversionRate(String conversionRate) {
    this.conversionRate = conversionRate;
  }
  public double getFoutStorageQty() {
		return foutStorageQty;
	}
	public void setFoutStorageQty(double foutStorageQty) {
		this.foutStorageQty = foutStorageQty;
	}
	
}
